package com.lotusfall.service;

import com.lotusfall.api.ApiUserService;
import com.lotusfall.pojo.User;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


@Service
public class UserService {
    @DubboReference(version ="1.0")
    private ApiUserService apiUserService;


    public User getUserById(Long id) {
        return apiUserService.getUserById(id);
    }

    public User getCurrentUser() {
        return apiUserService.getCurrentUser();
    }

    public Map<Long,User> getAll() {
        List<User> all = this.apiUserService.queryAll();
        System.out.println("all:" + all.size());
        Map<Long,User> result = new HashMap<>();
        all.forEach(user -> {
            result.put(user.getId(), user);
        });
        return result;
    }
}
